#include <iostream>
using namespace std;


class Date
{
    friend istream& operator>>(istream& in, Date& d);
    friend ostream& operator<<(ostream& out, const Date& d);
public:
    Date()
    {}

    Date(int year, int month, int day)
        :_year(year)
        , _month(month)
        , _day(day)
    {
        if (!(Assert()))
        {
            exit(-1);
        }
    }

    ~Date()
    {
        _year = 0;
        _month = 0;
        _day = 0;
    }
    bool Assert()
    {
        if (_month > 0 && _month < 13)
        {
            if (_day > 0 && _day <= getmonth())
            {
                return true;
            }
        }
        return false;
    }

    bool leapyear() const
    {
        if ((_year % 4 == 0 && _year % 100 != 0) || _year % 400 == 0)
            return true;
        return false;
    }

    int getmonth() const
    {
        int montharr[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
        if (_month == 2 && leapyear())
        {
            return 29;
        }
        return montharr[_month];
    }

    Date& operator-=(int day)
    {
        _day -= day;
        if (_day <= 0)
        {
            _month--;
            if (_month == 0)
            {
                _year--;
                _month = 12;
            }
            _day += getmonth();
        }
        return *this;
    }

    int WhatDays()
    {
        while (_month > 1)
        {
            _month--;
            _day += getmonth();
        }
        return _day;
    }

private:
    int _year = 2024;
    int _month = 11;
    int _day = 11;
};

istream& operator>>(istream& in, Date& d)
{
    in >> d._year >> d._month >> d._day;

    if (!(d.Assert()))
    {
        exit(-1);
    }

    return in;
}

ostream& operator<<(ostream& out, const Date& d)
{
    out << d._year << " " << d._month << " " << d._day << endl;
    return out;
}


int main()
{
    Date a;
    cin >> a;
    cout << a.WhatDays() << endl;

    return 0;
}